package com.xlisteven.fallback;

import com.xlisteven.entity.Product;
import com.xlisteven.feign.ProductClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
public class ProductFallback implements FallbackFactory<ProductClient> {
    @Override
    public ProductClient create(Throwable throwable) {
        return new ProductClient() {
            @Override
            public List<Product> getProductList(long userId) {
                log.info("商品开始降级处理,{}", userId);
                return null;
            }

            @Override
            public void insert(List<Product> productList) {
                log.info("商品插入失败");
            }
        };
    }
}
